#!/bin/bash

echo "=========================================="
echo "   小型数据库系统 - 运行菜单"
echo "=========================================="
echo ""
echo "请选择要运行的组件:"
echo "1. Python词法分析器"
echo "2. Python语法分析器"
echo "3. C++词法分析器"
echo "4. C++语法分析器"
echo "5. C++文件管理器"
echo "6. 运行所有测试"
echo "0. 退出"
echo ""

read -p "请输入选择 (0-6): " choice

case $choice in
    1)
        echo ""
        echo "运行Python词法分析器..."
        cd /Users/zhangpeng/Desktop/150
        python3 sql_compiler/lexer.py
        ;;
    2)
        echo ""
        echo "运行Python语法分析器..."
        cd /Users/zhangpeng/Desktop/150/sql_compiler
        python3 parser.py
        ;;
    3)
        echo ""
        echo "运行C++词法分析器..."
        cd /Users/zhangpeng/Desktop/150/sql_compiler_cpp
        make clean > /dev/null 2>&1
        make > /dev/null 2>&1
        ./test_parser
        ;;
    4)
        echo ""
        echo "运行C++语法分析器..."
        cd /Users/zhangpeng/Desktop/150/sql_compiler_cpp
        make clean > /dev/null 2>&1
        make > /dev/null 2>&1
        ./test_parser
        ;;
    5)
        echo ""
        echo "运行C++文件管理器..."
        cd /Users/zhangpeng/Desktop/150/storage_system_cpp
        make clean > /dev/null 2>&1
        make > /dev/null 2>&1
        ./test_file_manager
        ;;
    6)
        echo ""
        echo "运行所有测试..."
        cd /Users/zhangpeng/Desktop/150
        ./run_all_tests.sh
        ;;
    0)
        echo "退出程序"
        exit 0
        ;;
    *)
        echo "无效选择，请重新运行脚本"
        exit 1
        ;;
esac

echo ""
echo "=========================================="
